<?php
require_once '../../includefiles.php';
require_once "../../model/testimonials.php";
require_once "../../includes/classes/paging_htacess.php";

## creating objects of required models

$testimonialObj = new Model_Testimonial();




## for pagination
	$page = $_GET['id1'];
	if(!isset($_GET['id1']))
	$page = 1;
	else
	$page = $page;
	
## limit per pag 
$tetsimonialPerPage = 10;
$StartRow = $tetsimonialPerPage  * ($page-1);
## Getting all testimonials from database



$testimonialArray  = $testimonialObj->list_TestimonialFrontwithlimit($tetsimonialPerPage,$StartRow,false);
$totalCount        = count($testimonialArray);
$smarty -> assign("recordsFound",$totalCount);

$res = $testimonialObj->list_TestimonialFrontwithlimit($tetsimonialPerPage,$StartRow,true);

$i=0;
	foreach ($res as $rs)
	{
		$resultOfEachTestimonial = $testimonialObj->list_TestimonialDetailsById($rs['id']);
		$res[$i]['description']  = $rs['description'];
		$res[$i]['firstname']    = $rs['firstname'];
		$res[$i]['lastname']     = $rs['lastname'];				 
		
		$i++;
	}
$show = 1;
$total_pages = ceil($totalCount / $tetsimonialPerPage);
	if($total_pages > 1)
	$smarty -> assign("showpgnation","yes");
	$showing    = !isset($_GET["id1"]) ? 1 : $page;
	## it shoould be file name 
	$firstlink  = "testimonials/";
	
	$baselink   = $firstlink;
	$pagenation = pagination($total_pages, $show, $showing, $firstlink, $baselink, "", "testimonials");
	$smarty -> assign("pagenation", $pagenation);
	$smarty -> assign("page", $page);
	//echo "<pre>"; print_r($res);exit;
	$smarty->assign("testimonialArray", $res);

/*$smarty->assign('testimonialArray',$testimonialArray);*/
 $smarty->assign('subactive',"manage");
$smarty->display(TEMPLATEDIR . 'modules/testimonial/testimonials.tpl');
?>